-
Notifications
You must be signed in to change notification settings - Fork 25.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Painless: Move More Logic to PainlessLookup #32689
Conversation
Pinging @elastic/es-core-infra |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, but I think we should return null instead of using exceptions to indicate a class is not found.
return handle; | ||
try { | ||
return painlessLookup.lookupRuntimeSetterMethodHandle(receiverClass, name); | ||
} catch (IllegalArgumentException iae) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should use IAE as control flow. Can we return null if the the class is not found and base these special cases on that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
@@ -174,4 +177,76 @@ public PainlessMethod lookupFunctionalInterfacePainlessMethod(Class<?> targetCla | |||
|
|||
return functionalInterfacePainlessMethod; | |||
} | |||
|
|||
public PainlessMethod lookupRuntimePainlessMethod(Class<?> originalTargetClass, String methodName, int methodArity) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add at least a single line javadoc to these methods (and preferably the other ones as well here, although that could be in a followup)? It is getting difficult to understand what the differences in expected behavior are, eg based on a single word difference here of adding "runtime" to the method name, but taking the same args as lookupPainlessMethod
above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to add documentation for all of these in a follow up PR as there are a few more changes lined up and I would prefer not to write it twice over the next couple weeks if that's okay.
@rjernst Thanks for the review. I changed all the methods in PainlessLookup to return null and react at the site of the calls instead of using exception handling as control flow. Ready for another round. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@rjernst Thanks for the reviews! |
This moves some run-time lookups for methods and fields to the PainlessLookup.
This moves some run-time lookups for methods and fields to the PainlessLookup.